package com.zxy.zxyrpc.protocol;

import lombok.Getter;

/**
 * 协议消息的状态枚举
 *
 * @author zxy
 * @since 2025/5/22
 **/
@Getter
public enum ProtocolMessageStatusEnum {
    OK("ok", 20),
    BAD_REQ("BadReq", 40),
    BAD_RES("BadRes", 50);

    private final String text;
    private final int value;

    ProtocolMessageStatusEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value 状态值
     * @return 状态信息
     */
    public static ProtocolMessageStatusEnum getEnumByValue(int value) {
        for (ProtocolMessageStatusEnum anEnum : ProtocolMessageStatusEnum.values()) {
            if (anEnum.value == value)
                return anEnum;
        }
        return null;
    }
}
